import Vue from 'vue'
import VueRouter from 'vue-router'
// import Index from '@/views/index'
// import Home from '@/views/home/index.vue'
// import Login from '@/views/login/login.vue'
// import AllShops from '@/views/list/allShop'
// import ShopDetails from '@/views/details/viewDetails'
// import User from '@/views/user/user'

const Index = () => import('@/views/index')
const Home = () => import('@/views/home/index.vue')
const Login = () => import('@/views/login/login.vue')
const AllShops = () => import('@/views/list/allShop')
const ShopDetails = () => import('@/views/details/viewDetails')
const User = () => import('@/views/user/user')

Vue.use(VueRouter)

const routes = [{
    path: '/',
    redirect: '/home',
    component: Index,
    children: [{
        path: '/home',
        component: Home
      },
      // 全部
      {
        path: '/all',
        component: AllShops
      },
      {
        // 查看商品详情
        path: '/shopDetails',
        component: ShopDetails
      }

    ]
  },
  {
    path: '/login',
    component: Login
  },
  {
    path: '/user',
    component: User,
    meta: {
      requireAuth: true // 添加该字段，表示进入这个路由是需要登录的
    }
  }
]
const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
